package exam.driver.jdbc;

public class WhereSimple<T> {
	// luu giu cau dieu kien where
	protected StringBuffer whereString;
	
	/**
	 * constructor
	 */
	protected WhereSimple() {
		this.whereString = new StringBuffer();
	}
	
	/**
	 * eq
	 * @param field
	 * @param value
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public T eq(String field, Object value) {
		this.whereString.append(field).append("='").append(value).append("'");
		return (T) this;
	}
	/**
	 * eq
	 * @param key
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public T eq(String field) {
		this.whereString.append(field).append("=").append("?");
		return (T) this;
	} 
	/**
	 * AND
	 */
	@SuppressWarnings("unchecked")
	public T and() {
		this.whereString.append(" AND ");
		return (T) this;
	}
	
	/**
	 * OR
	 */
	@SuppressWarnings("unchecked")
	public T or() {
		this.whereString.append(" OR ");
		return (T) this;
	}
}
